package Exercises;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/7/2 15:41
 */

import java.util.*;

public class Same_Cage {
    public static void main(String[] args) {
        int x = 0;
        int y = 0;
        int Sum, Foot;
        System.out.println("请输入一共有多少只动物：");
        Sum = new Scanner(System.in).nextInt();
        System.out.println("请输入一共有多少只脚：");
        Foot = new Scanner(System.in).nextInt();
        x = Sum;
        while ((x + y) == Sum && (2 * x + 4 * y) != Foot) {
            do {
                --x;
                ++y;
            }
            while ((2 * x + 4 * y) != Foot);
            break;
        }
        System.out.println("一共有" + x + "只鸡" + "一共有" + y + "只兔子");
    }
}
